home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’93 / Listen to your hack…beat / trap patches / patches.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  1.9 KB  |  140 lines  |  [TEXT/KAHL]

  1. #include "const.h"
  2. #include "globals.h"
  3. #include "utils.h"
  4. #include "patches.h"
  5.  
  6. #include "midistuff.h"
  7.  
  8. #define GNEChannel    1
  9. #define GNEVoice    116
  10. #define GNEPitch    20
  11. #define GNEVelocity    64
  12.  
  13. #define FRChannel    2
  14. #define FRVoice        31
  15. #define FRPitch        40
  16. #define FRVelocity    100
  17.  
  18. #define IUChannel    3
  19. #define IUVoice        14
  20. #define IUPitch        70
  21. #define IUVelocity    100
  22.  
  23. #define TKChannel    4
  24. #define TKVoice        10
  25. #define TKPitch        60
  26. #define TKVelocity    120
  27.  
  28.  
  29. #define UpdateInterval    20
  30. unsigned long lastUpdate;
  31. void InitGlobals(void)
  32. {
  33.     lastUpdate = 0L;
  34. }
  35.  
  36. void UpdateChannels( void)
  37. {
  38.     unsigned long now;
  39.     GetDateTime(&now);
  40.     if (now > (lastUpdate + UpdateInterval))
  41.         {
  42.         lastUpdate = now;
  43.         ProgramChannels();
  44.         }
  45. }
  46.  
  47. void ProgramChannels( void)
  48. {
  49.     SetProgramChannel(GNEChannel, GNEVoice);
  50.     SetProgramChannel(FRChannel, FRVoice);
  51.     SetProgramChannel(IUChannel, IUVoice);
  52.     SetProgramChannel(TKChannel, TKVoice);
  53. }
  54.  
  55.  
  56.  
  57. OSErr PGetNextEvent(void)
  58. {    
  59.     Ptr nextLink;
  60.     
  61.     SetUpA4();
  62.     
  63.     nextLink = gGetNextEventLink;
  64.  
  65.     InitMidi();
  66.     UpdateChannels();
  67.     
  68.     StartNote(GNEChannel, GNEPitch, GNEVelocity);
  69.     
  70.     asm {
  71.         move.l    (sp)+,a4
  72.         move.l    nextLink,a1
  73.         unlk    a6
  74.         jmp        (a1)
  75.     }
  76. }
  77.  
  78.  
  79. OSErr PFrameRect(Rect *whichRect)
  80. {    
  81.     Ptr nextLink;
  82.     long area;
  83.     
  84.     SetUpA4();
  85.     
  86.     nextLink = gFrameRectLink;
  87.     area = (long)(whichRect->right - whichRect->left) * (whichRect->bottom - whichRect->top);
  88.     
  89.     StartNote(FRChannel, 127 - area/3000, FRVelocity);
  90.     
  91.     asm {
  92.         move.l    (sp)+,a4
  93.         move.l    nextLink,a1
  94.         unlk    a6
  95.         jmp        (a1)
  96.     }
  97. }
  98.  
  99. OSErr PIconUtils(void)
  100. {    
  101.     Ptr nextLink;
  102.     
  103.     asm
  104.     { move.l d0,-(sp) }
  105.     SetUpA4();
  106.  
  107.     nextLink = gIconUtilsLink;
  108.  
  109.     StartNote(IUChannel, IUPitch, IUVelocity);
  110.  
  111.     asm {
  112.         move.l    (sp)+,a4
  113.         move.l    (sp)+,d0
  114.         move.l    nextLink,a1
  115.         unlk    a6
  116.         jmp        (a1)
  117.     }
  118. }
  119.  
  120.  
  121. OSErr PTEKey(Handle te,short key)
  122. {    
  123.     Ptr nextLink;
  124.  
  125.     SetUpA4();
  126.     
  127.     nextLink = gTEKeyLink;
  128.     
  129.     StartNote(TKChannel, (key & 0x3f) + 64, TKVelocity);
  130.     
  131.     asm {
  132.         move.l    (sp)+,a4
  133.         move.l    nextLink,a1
  134.         unlk    a6
  135.         jmp        (a1)
  136.     }
  137. }
  138.  
  139.  
  140.